import time

List = [4, 2, 2, 67, 23, 87, 12, 987, 123, 34, 76, 89]
# List = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

# start = time.perf_counter()
while True:
    # 初始状态为1
    state = 1
    for i in range(len(List) - 1):  # i会从0开始
        if List[i] > List[i + 1]:
            n = List[i]
            List[i] = List[i + 1]
            List[i + 1] = n
            state = 0
    # 如果无需交换就表示已经排序完毕，跳出循环
    if state:
        break
# end = time.perf_counter()
# print("cpu计算时间*100000：", 100000 * (end - start))
print(List)
